import React, { Fragment } from 'react';
import { Provider } from 'react-redux';
import { BrowserRouter, Route } from 'react-router-dom';
import Header from './common/header'
import Home from './pages/home'
import Detail from './pages/detail/loadable.js'
import Login from './pages/login'
import Write from './pages/write'
import state from './store/index'

const App = () => {
  return (
    <Provider store={state}>
      <Fragment>{/*必须只含有一个标签*/}
        <BrowserRouter> {/*路由*/}
          <Fragment>
            <Header />
            <Route exact path="/login" component={Login}/>
            <Route exact path="/write" component={Write}/>
            <Route exact path="/" component={Home} /> {/*路由规则*/}
            <Route exact path="/detail/:id" component={Detail} />
          </Fragment>
        </BrowserRouter>
      </Fragment>
    </Provider>
  )
};

export default App;